using MediatR;
using SumerCoreDevOps.Application.Nodes.Queries;
using SumerCoreDevOps.Domain.Entities;
using SumerCoreDevOps.Infrastructure.Scheduling;

namespace SumerCoreDevOps.Application.Nodes.Handlers;

/// <summary>
/// 获取所有在线节点查询处理器
/// </summary>
public class GetOnlineNodesQueryHandler : IRequestHandler<GetOnlineNodesQuery, List<NodeStatus>>
{
    private readonly NodeManager _nodeManager;

    public GetOnlineNodesQueryHandler(NodeManager nodeManager)
    {
        _nodeManager = nodeManager;
    }

    public async Task<List<NodeStatus>> Handle(GetOnlineNodesQuery request, CancellationToken cancellationToken)
    {
        return await _nodeManager.GetOnlineNodesAsync();
    }
}
